/**
 * 
 */
package com.whu.waterworks.impl;

import java.util.ArrayList;


import org.springframework.orm.hibernate4.HibernateTemplate;

import com.whu.waterworks.dao.WaterPlantNormDao;
import com.whu.waterworks.model.WaterPlantNorm;

/**
 * @author： Joymin
 * @date：2016-4-1 上午9:29:46
 * 说明: 
 */
public class WaterPlantNormDaoImpl implements WaterPlantNormDao{

    private HibernateTemplate hibernateTemplate;
	
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
	/* (non-Javadoc)
	 * @see com.whu.waterworks.dao.WaterPlantNormDao#saveWaterPlantNorm(com.whu.waterworks.model.WaterPlantNorm)
	 */
	@Override
	public boolean saveWaterPlantNorm(WaterPlantNorm norm) {
		// TODO Auto-generated method stub
		hibernateTemplate.save(norm);
		return true;
	}

	/* (non-Javadoc)
	 * @see com.whu.waterworks.dao.WaterPlantNormDao#updateWaterPlantNorm(com.whu.waterworks.model.WaterPlantNorm)
	 */
	@Override
	public boolean updateWaterPlantNorm(WaterPlantNorm norm) {
		// TODO Auto-generated method stub
		hibernateTemplate.merge(norm);
		return true;
	}

	/* (non-Javadoc)
	 * @see com.whu.waterworks.dao.WaterPlantNormDao#getWaterPlantNormById(java.lang.String)
	 */
	@Override
	public WaterPlantNorm getWaterPlantNormById(String waterPlantId) {
		// TODO Auto-generated method stub
		@SuppressWarnings("unchecked")
		ArrayList<WaterPlantNorm> rs =(ArrayList<WaterPlantNorm>) hibernateTemplate.find("from  WaterPlantNorm _WaterPlantNorm  where _WaterPlantNorm.waterPlantId='"+waterPlantId+"'");		
		if(null!=rs && rs.size()>0){
			return rs.get(0);
		}
		return null;
	}

}
